import { defineStore } from 'pinia'
import { getCinemaList } from '@/api/modules/cinema'
import type { Cinema } from '@/api/interface'

export const useCinemaStore = defineStore('cinema', {
  state() {
    return {
      items: [] as Cinema.Item[] // 用于存放影院列表数据
    }
  },

  actions: {
    /**
     * 获取影院列表数据
     */
    async getItems(data: { cityId: number; ticketFlag: number }) {
      const { cinemas } = await getCinemaList(data)
      this.items = cinemas

      // 可以将 cinemas 再 return 出去
      return cinemas
    }
  }
})
